using System.Diagnostics;

namespace PKGames.Analytics
{
	public class PlayGameEventController
	{
		private readonly PlayGameEvent _playGameEvent;

		private readonly Stopwatch _timeUsageStopwatch;

		public PlayGameEventController(string gameName, string gameLevel, string origin)
		{
			_playGameEvent = new PlayGameEvent(origin, gameName, gameLevel);
			_timeUsageStopwatch = new Stopwatch();
			_timeUsageStopwatch.Start();
		}

		public void LogEvent()
		{
			_timeUsageStopwatch.Stop();
			_playGameEvent.SetTimeUsage((float)_timeUsageStopwatch.ElapsedMilliseconds / 1000f);
			_playGameEvent.Finish();
			_playGameEvent.Log();
		}
	}
}
